<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="/home/css/_reset.css" />
		<link rel="stylesheet" type="text/css" href="/home/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/home/css/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="/home/css/login.css" />
		<style>
	        input::-webkit-input-placeholder{
	            color:#fff;
	        }
	        input::-moz-placeholder{   /* Mozilla Firefox 19+ */
	            color:#fff;
	        }
	        input:-moz-placeholder{    /* Mozilla Firefox 4 to 18 */
	            color:#fff;
	        }
	        input:-ms-input-placeholder{  /* Internet Explorer 10-11 */ 
	            color:#fff;
	        }
	    </style>
	</head>
	<body style="overflow-x: hidden;">
		<div class="login row">
			<div class="container-fluid">
				<div class="wrap row">
					<div class="logo">
						<img src="/home/img/logo.png" />
					</div>
					<div class="phone">
						<i class="iconfont">&#xe616;</i><input type="text" name="u_tel" id="phone" value="" placeholder="请输入手机号码" />
					</div>
					<div class="num row">
						<i class="iconfont">&#xe69c;</i><input type="text" name="code" id="dxcode" value="" class="col-sm-8 col-xs-8" placeholder="请输入验证码"/>
						<input type="button" id="clickcode" value="获取验证码" class="col-sm-4 col-xs-4" style="padding-left:1%;background-color: #fff;color:#000"/> 
					</div>
					<a id="btn">确定</a>
					<div class="wechat">
						<div class="tit row">
							<i></i>
						<p class="tis">第三方登录</p>
						</div>
						<p class="disan">
							<a href="#"><i class="iconfont">&#xe651;</i></a>
							<a href="#"><i class="iconfont">&#xe61a;</i></a>
						</p>
					</div>
				</div>
			</div>
			<div class="make"></div>
		</div>
	</body>
	<script src="/home/js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
    <script src="/home/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/home/js/iconfont.js" type="text/javascript" charset="utf-8"></script>
	<script src="/home/layer/layer.js"></script>
	<script type="text/javascript">
	$(".wrap").css("margin-top", "-" + $(".wrap").height()/2 + "px");
	// 点击获取验证码
    $("#clickcode").click( function () { 
    	var phone=$("#phone").val();//获取注册号码
    	// alert(user);
        var reg = /^1[345678]\d{9}$/; 
        if(phone===""){

        	layer.msg('手机号码不能为空',{icon:5});

        	return false;

        }else if(!reg.test(phone)){
     
            layer.msg('手机号码格式错误',{icon:5});
            
            return false;

        }else{
        	$.post('/home/login/getCode',{phone:phone},function(res){
        		var data = res.data.data;
        		var phone = res.data.phone;
		   		if(data.Message !=="ok"){
		   			return false;
		   		}else{
		   			$('#telphone').attr('value',phone);
		   		}

        	},'json');
        		
   			var i = 60;

	    	// 4.启动定时器
	    	var timer = setInterval(function(){

	    		$("#clickcode").attr('disabled',true);
	    		// 5.修改标签之间的内容
       			$("#clickcode").attr('value',+i+'s');

	    		// 6.秒数递减
	    		i--;

	    		// 7.定时器的停止条件
	    		if(i <= 0){
	    			clearInterval(timer);

		    		$("#clickcode").attr('disabled',false);

	       			$("#clickcode").attr('value','重新获取验证码');

	    		}

	    	},1000);
	    	return false;
		}
	});

    /* 验证登录信息 */
    $('#btn').click(function(){
    	var u_tel =$("#phone").val();
    	var code  = $('#dxcode').val();

    	if(u_tel === ''){
    		layer.mag('手机号码不能为空',{icon:5});
    	}else if(code === ''){
    		layer.msg('验证码不能为空',{icon:5});
    	}else{
    		$.post('/home/login/postDologin',{u_tel:u_tel,code:code},function(res){
    			if(res.msg == '登录成功'){
    				layer.msg(res.msg , {icon:6});
                    setTimeout(function(){
                        window.location.href="{:url('/home/Index/index')}";
                    },2000);
    			}else if(res.msg=="该手机号码已注册"){
    				layer.msg(res.msg , {icon:5});
    				return false;
    			}else if(res.msg=="手机号码与发短信的号码不一致"){
    				layer.msg(res.msg, {icon:5});
    				return false;
    			}else if(res.msg=="验证码错误"){
    				layer.msg(res.msg, {icon:5});
    				return false;
    			}else if(res.msg=="该手机号码未注册"){
    				setTimeout(function(){
                        window.location.href="/home/login/recommend?u_tel="+u_tel+"";
                    },1000);
    			}
    		},'json');
    	}
    });
	</script>
</html>